package com.slofzx.nuoda.evaluation.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.slofzx.nuoda.common.EnumConfig;
import com.slofzx.nuoda.common.enums.DataFormatEnum;
import com.slofzx.nuoda.common.enums.OfficeType;

/**
 * 组织架构类型
 *
 * @author sunfuyong
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@EnumConfig(id="office-type",name="组织机构类型",valueFormat = DataFormatEnum.JSON,primary = true)
public enum CustomOfficeTypeEnum implements OfficeType {

    RESEARCH("research", "科研机构",1, false),
    DEPARTMENT("department", "机关部门",2, true),
    WHOLLY_OWNED("wholly_owned", "直属全资公司",3, false),
    HOLDING("holding", "直属控股公司",4, false,true),
    SHARE_PARTICIPATION("share_participation", "直属参股公司",5, false,true),
    BRANCH_OFFICE("branch_office", "直属子公司",6, false),
    SUB_OFFICE("sub_office", "二级单位",0, false);;

    /**
     * 标识id
     */
    private String id;

    /**
     * 名称
     */
    private String name;

    /**
     * 排序值
     */
    private double sort;
    /**
     * 是否为最终节点
     */
    private boolean leaf;

    /**
     * 自定义股比
     */
    private boolean customStock;


    CustomOfficeTypeEnum(String id, String name, double sort, boolean leaf) {
        this.id = id;
        this.name = name;
        this.leaf = leaf;
        this.sort = sort;
    }
    CustomOfficeTypeEnum(String id, String name, double sort, boolean leaf, boolean customStock) {
        this.id = id;
        this.name = name;
        this.leaf = leaf;
        this.customStock = customStock;
        this.sort = sort;
    }

    public static CustomOfficeTypeEnum getEnum(String id) {
        for (CustomOfficeTypeEnum typeEnum : values()) {
            if (typeEnum.id.equals(id)) {
                return typeEnum;
            }
        }
        return null;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    @Override
    public boolean isLeaf() {
        return leaf;
    }

    @Override
    public boolean isCustomStock() {
        return customStock;
    }

    @Override
    public double getSort() {
        return this.sort;
    }
}
